//
//  SettingViewController.swift
//  ShopIOS
//
//  Created by Apple on 2019/7/18.
//  Copyright © 2019 Apple. All rights reserved.
//

import UIKit

class SettingViewController: UIViewController {
    
    @IBOutlet weak var uv_back: UIView!
    @IBOutlet weak var uv_info: UIView!
    @IBOutlet weak var uv_address: UIView!
    @IBOutlet weak var uv_pwd: UIView!
    @IBOutlet weak var uv_pay_pwd: UIView!
    @IBOutlet weak var uv_clear: UIView!
    @IBOutlet weak var uv_feedback: UIView!
    @IBOutlet weak var uv_aboutus: UIView!
    @IBOutlet weak var btn_logout: UIButton!
    @IBOutlet weak var uiv_avator: UIImageView!
    @IBOutlet weak var lb_nick: UILabel!
    @IBOutlet weak var lb_account: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        btn_logout.layer.cornerRadius=25
        uiv_avator.layer.cornerRadius=30
        uv_back.addOnClickListener(target: self, action:#selector(back))
        uv_info.addOnClickListener(target: self, action:#selector(info))
        uv_address.addOnClickListener(target: self, action:#selector(address))
        uv_pwd.addOnClickListener(target: self, action:#selector(pwd))
        uv_pay_pwd.addOnClickListener(target: self, action:#selector(paypwd))
        uv_clear.addOnClickListener(target: self, action:#selector(clear))
        uv_feedback.addOnClickListener(target: self, action:#selector(feedback))
        uv_aboutus.addOnClickListener(target: self, action:#selector(aboutus))
        btn_logout.addOnClickListener(target: self, action:#selector(logout))
        // Do any additional setup after loading the view.
    }
    @objc func info(){
        self.navigationController?.pushViewController(PersonalInfoViewController(), animated: true)
    }
    @objc func address(){
        self.navigationController?.pushViewController(AddressViewController(choose: false), animated: true)
    }
    @objc func pwd(){
        self.navigationController?.pushViewController(LoginViewController(), animated: true)
    }
    @objc func paypwd(){
        self.navigationController?.pushViewController(LoginViewController(), animated: true)
    }
    @objc func feedback(){
        self.navigationController?.pushViewController(LoginViewController(), animated: true)
    }
    @objc func aboutus(){
        self.navigationController?.pushViewController(LoginViewController(), animated: true)
    }
    @objc func clear(){
        self.navigationController?.pushViewController(LoginViewController(), animated: true)
    }
    @objc func logout(){
        UserDefaults.standard.removeObject(forKey: "UserKey")
        UserDefaults.standard.removeObject(forKey: "UserID")
        UserDefaults.standard.removeObject(forKey: "adminToken")
        userkey=UserDefaults.standard.string(forKey: "UserKey")
        UserID=UserDefaults.standard.string(forKey: "UserID")
        adminToken=UserDefaults.standard.string(forKey: "adminToken")
        NotificationCenter.default.post(name: NSNotification.Name("logout"), object: nil)
        self.navigationController?.popToRootViewController(animated: true)
    }
    @objc func back(){
        self.navigationController?.popViewController(animated: true)
    }
    
    /*
     // MARK: - Navigation
     
     // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destination.
     // Pass the selected object to the new view controller.
     }
     */
    
}
